package some.coupon.admin.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import some.coupon.admin.dao.ACouponDao;

@Controller
public class ACouDelHidController {
	
	private Logger log = Logger.getLogger(this.getClass());
	
	@Autowired
	private ACouponDao aCouponDao;
		
	@RequestMapping("/aCouDelHid.do")
	public ModelAndView submit(HttpServletRequest request){
		
		if(log.isDebugEnabled()){
		}
		
		int aCouListSize = Integer.parseInt(request.getParameter("aCouListSize"));
		
		for(int i=1; i<=aCouListSize; i++){
			String cou_id = request.getParameter(""+i);
			String checked = request.getParameter("hiding["+i+"]");

			if(checked == null){
				aCouponDao.setShow(cou_id);
			}else{
				aCouponDao.setHiding(cou_id);
			}
		}

		ModelAndView mav = new ModelAndView("aCouDelHid");
		
		return mav;
	}
	
}

